package com.thinkgem.jeesite.modules.sys.utils;
/**
 * 
 * @ClassName:  ResponseObject   
 * @Description:   封装返回数据的响应
 * @author: 胡章林
 * @date:   2017年8月12日 下午12:03:53   
 */
public class ResponseObject<T>  {
	
	private Integer code;
	private String message;
	private T Data;
	
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public ResponseObject failResponse(Object data) {
		ResponseObject res = new ResponseObject(ResponseEnum.sucess);
		res.setData(data);
		return res;
		
	}
	@SuppressWarnings("rawtypes")
	public static ResponseObject failResponse(ResponseEnum  responseEnum) {
		return new ResponseObject(responseEnum);
	}
	
	
	@SuppressWarnings("rawtypes")
	public static ResponseObject failResponse(Integer code,String message) {
		return new ResponseObject(code,message);
	}
	
	
	@SuppressWarnings("rawtypes")
	public static ResponseObject<?> failResponse() {
		return new ResponseObject(ResponseEnum.fail);
	}
	
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static ResponseObject successResponse(Object data) {
		ResponseObject res = new ResponseObject(ResponseEnum.sucess);
		res.setData(data);
		return res;
		
	}
	@SuppressWarnings("rawtypes")
	public static ResponseObject successResponse(ResponseEnum  responseEnum) {
		return new ResponseObject(responseEnum);
	}
	
	
	@SuppressWarnings("rawtypes")
	public static ResponseObject successResponse(Integer code,String message) {
		return new ResponseObject(code,message);
	}
	
	@SuppressWarnings("rawtypes")
	public static ResponseObject<?> successResponse() {
		
		return new ResponseObject(ResponseEnum.sucess);
	}
	
	 
	public ResponseObject(ResponseEnum responseEnum) {
		this(responseEnum.getCode(),responseEnum.getMessage());
	}
	
	public ResponseObject(Integer code , String message){
		this.code = code ;
		this.message = message;
	}
	
	public ResponseObject() {
		super();
	}
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public T getData() {
		return Data;
	}
	public void setData(T data) {
		Data = data;
	}
	
}
